home *** CD-ROM | disk | FTP | other *** search
- /*
- FILE: ringmod.c
- PROJECT: Ford grant DSP
- AUTHOR: Ben Denckla
- COMMENTS: fixed-frequency sinusoidal-carrier ring modulation
- LINKAGE: needs sintab.c
- */
-
- #include "aiff.h"
- #include "sintab.h"
-
- #include <stdlib.h>
-
- int take_input = 1, make_output = 1;
-
- static short *sintab4, harm;
-
- void init_process( void ) {
- if ( (ba.com.wdsi < 9) || (ba.com.wdsi > 16) )
- err( "Cannot process a file with this word size" );
- if ( ba.com.chan != 1 )
- err( "Cannot process a multi-channel file" );
-
- get_sintab(); // get a 1st-quadrant sine wave table
- sintab4 = gen_sintab4(); // generate a 4-quadrant sine wave table
- harm = getusrharm(); // get harmonic desired from user
- }
-
- void term_process( void ) {
- free ( sintab4 );
- }
-
- void process_samdat( long buflen ) {
- register long t;
- register short *td, *endd, *tsintab4, tharm, tphase, ttabmask;
- static short phase = 0;
-
- td = d;
- tsintab4 = sintab4;
- tharm = harm;
- tphase = phase;
- ttabmask = TABMASK;
- endd = &td[buflen];
-
- do {
- t = (long) *td * tsintab4[ tphase &= ttabmask ];
- asm { swap t }; // 1
- *td++ = t;
- tphase += tharm; // 2
- } while ( td < endd );
-
- phase = tphase;
- }
- /*
- 1. To profile, use t >>= 16 instead. (Can't profile a function w/ asm.)
-
- loop:
- 00000026 AND.W ttabmask,tphase
- 00000028 MOVE.W $00(tsintab4,tphase.W*2),D7
- 0000002C MULS.W *td,D7
- 0000002E SWAP D7
- 00000030 MOVE.W D7,*td++
- 00000032 ADD.W harm,tphase
- 00000034 CMPA.L td,end
- 00000036 BHI.S loop
- */